/**
 * author:Administrator
 * date:2016/2/24
 * desc:TODO
 */

'use strict';

var RepoImpl = require('../../../infrastructure/persist').WareRepoImpl;
var SnapshotRepoImpl = require('../../../infrastructure/persist').WareSnapshotRepoImpl;

class WareRepo {

  /**
   * @param ware
   * @param t transaction
   */
  static * store(ware, t) {
    yield RepoImpl.store(ware, t);
  }

  /**
   * 减少数量
   * @param id
   * @param count
   * @param t
   */
  static * decrease(id, count, t) {
    return yield RepoImpl.decrease(id, count, t);
  }

  /**
   * @param wareSnapshot
   * @param t transaction
   */
  static * storeSnapshot(wareSnapshot, t) {
    yield SnapshotRepoImpl.store(wareSnapshot, t);
  }


  static * find(id) {
    return yield RepoImpl.find(id);
  }

  static * findSnapshot(id) {
    return yield SnapshotRepoImpl.find(id);
  }


  static * findSnapshotByWare(wareInfo) {
    return yield SnapshotRepoImpl.findByWare(wareInfo);
  }

}

module.exports = WareRepo;
